﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using System;
using System.Linq;
using KFGame;

public class SubmitRank : KFTask
{


    public string server = "";

    public string gname = "yysc";

    string url = "/api/index/uploadtop";
    string ctag = "uploadtop";


    void Awake()
    {


    }


    public void toSendDatas(KFGame.RankData data)
    {

        uploadRank(data);
    }

    void uploadRank(KFGame.RankData rdata)
    {
        Debug.Log("send datas");

        WWWForm form = new WWWForm();
        form.AddField("car_code", rdata.carname);
        form.AddField("gname", gname);
        form.AddField("head", rdata.handimg);
        form.AddField("score", rdata.count);
        form.AddField("device_id", "");
        form.AddField("city", "");
        form.AddField("gtime", "");
        form.AddField("decode", "");


    }
    void Event(string tag, string url, int id, string message)
    {
        Debug.Log("net call back :" + tag + ":" + id + ": url =" + url);

        if (tag != ctag)
            return;

        if (id == 404)
            return;

        if (id != 200)
            return;

        Debug.Log(message);
        var json = new MiniJSON2.JSON();
        json.serialized = message;

        if (json.ToInt("code") != 1)
            return;

    }
}
